class Solution {
public:
    int minStoneSum(vector<int>& piles, int k) {
        int num = 1;
        priority_queue<int> que;
        for (auto& x : piles) que.push(x);
        while (num <= k)
        {
            int temp = que.top();
            que.pop();
            que.push(temp - temp / 2);
            num += 1;
        }
        int ans = 0;
        while (!que.empty())
        {
            ans += que.top();
            que.pop();
        }
        return ans;
    }
};